Python Data Science Essentials - Second Edition by 2016
Given such input, the function wraps some other complex functions. It creates n-iterations, training a model of the n-cross-validation in-samples, testing the results, and storing scores derived at each iteration from the out-of-sample fold. In the end, the function reports a list of the recorded scores of this kind:
In: scores Out: array([ 0.96899225, 0.96899225, 0.9921875, 0.98412698, 0.99206349, 1, 1., 0.984, 0.99186992, 0.98347107])
The main advantage of using cross_val_score resides in its simplicity of usage and in the fact that it automatically incorporates all the necessary steps for a correct cross-validation. For example, when deciding how to split the train sample into folds, if a y vector is provided, it keeps the same target class label's proportion in each fold as it was in the y initially provided.